<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>高校健康云</title>

</head>
<header th:replace="header::html"></header>
<body class="index">

    <form class="layui-form" action="/user/update" method="post">
        <div class="layui-form-item" >
            <input type="text" name="id" id="updateid" value="">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">username</label>
            <div class="layui-input-block">
                <input type="text" name="username" id="username" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">password</label>
            <div class="layui-input-block">
                <input type="text" name="password" id="password" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">nickname</label>
            <div class="layui-input-block">
                <input type="text" name="nickname" id="nickname" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">email</label>
            <div class="layui-input-block">
                <input type="text" name="email" id="email" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>

    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function(data){
                $ = layui.jquery;
                var arr_box = [];
                $('input[type=checkbox]:checked').each(function() {
                    arr_box.push($(this).val());
                });
                //数组
                //data.field["physicalCondition"] = arr_box.join(",")
                // ajax 传输数据
                $.ajax({
                    url:"/user/update",
                    type:"POST",
                    contentType: "application/json; charset=utf-8",
                    data:JSON.stringify(data.field),
                    dataType:'json',
                    success:function(result){
                        layer.alert("添加成功", {icon: 6},function (index1) {
                            layer.close(index1);
                            location.reload()
                        });
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>